package com.matrix.common.exception;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.matrix.common.domain.Result;
import lombok.extern.slf4j.Slf4j;

/**
 * @author 有点甜
 * @since 2025/8/10
 */
@Slf4j
public class SentinelBlockExceptionHandler {

    public static Result<?> handleBlockException(Object... paramsAndException) {
        BlockException e = (BlockException) paramsAndException[paramsAndException.length - 1];
        log.warn("请求被Sentinel限流或降级, 规则: {}", e.getRule());
        return Result.error("请求过于频繁，请稍后再试");
    }
}
